/**
 * @file 设备查询DTO
 * @description 定义获取设备列表的请求参数
 * @author Assistant
 * @date 2024-06-01
 */

import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsEnum, IsString, IsInt, Min } from 'class-validator';
import { Type } from 'class-transformer';

/**
 * 设备状态枚举
 */
export enum DeviceStatus {
  OFFLINE = 0,
  ONLINE = 1,
  ALL = -1
}

/**
 * 设备查询参数DTO
 */
export class DeviceQueryDto {
  @ApiProperty({ 
    description: '设备状态', 
    required: false, 
    enum: DeviceStatus,
    default: DeviceStatus.ALL
  })
  @IsOptional()
  @Type(() => Number)
  @IsEnum(DeviceStatus)
  status?: DeviceStatus = DeviceStatus.ALL;

  @ApiProperty({ description: '搜索关键字', required: false })
  @IsOptional()
  @IsString()
  keyword?: string;

  @ApiProperty({ description: '查询日期（天）', required: false })
  @IsOptional()
  @IsString()
  date?: string; 

  @ApiProperty({ description: '当前页', required: false, default: 1 })
  @IsOptional()
  @IsInt()
  @Min(1)
  @Type(() => Number)
  page?: number = 1;

  @ApiProperty({ description: '每页限制', required: false, default: 100 })
  @IsOptional()
  @IsInt()
  @Min(1)
  @Type(() => Number)
  limit?: number = 100;
} 